<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="box">
      <div>1</div>
      <div class="box1">2</div>
      <div>3</div>
    </div>
  </body>
</html>
<script>
  //修改,替换元素
  var boxs = document.querySelector(".box");
  var box1s = document.querySelector(".box1");
  document.onclick = function () {
    var ele = document.createElement("div");
    ele.innerHTML = "我是创建的";
    boxs.replaceChild(ele, box1s);
  };
</script>
